﻿if (typeof Axis == "undefined") Axis = {};
Axis.Lottery = {
    Init: function () {
        this.GetResultLottery();
        intervalLottery = setInterval(Ramdom, 1000);
        intervalGetData = setInterval(Axis.Lottery.GetResultLottery, 1500);
    },
    GetResultLottery: function () {
        var pData = { ProjectID: 99 };
        $.ajax({
            url: 'Services/AxisLottery.asmx/GetCurrentResult',
            type: 'POST',
            data: JSON.stringify(pData),
            cache: false,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (pData, textStatus, jqXHR) {
                var data = eval("(" + pData.d + ")");
                $("#ProjectName").html(data.ProjectName);
                $("#PresentType").html(data.LuckyGift);

                $("#ContentPlaceHolder1_line1 div").removeClass('capability');
                //    var x = Math.floor((Math.random() * listNumber) + 1);LuckyGift
                //console.log(data.LuckyName);
                $("#NumberLucky").html(data.LuckyNumber);
                $("#MemberName").html(data.LuckyName);
                $("#line_" + data.LuckyNumber).addClass('capability');
                if (parseInt(data.LuckyNumber) == 999999) {
                    $("#ticketcontent").show();
                    $("#BlockResult").hide();
                }
                else {
                    $("#ticketcontent").hide();
                    $("#BlockResult").show();
                }

            },
            beforeSend: function (jqXHR, settings) {           //

            },
            error: function (jqXHR, textStatus, errorThrown) {
                //  overlay.Hide();
            },
            complete: function (XMLHttpRequest, textStatus) {
                // overlay.Hide();
            }
        });
    }
};

$(function () {
    Axis.Lottery.Init();
    // 
    GetMemberList();
});
function GetMemberList() {
    var pData = { ProjectID: 99 };
    $.ajax({
        url: 'Services/AxisLottery.asmx/GetListMember',
        type: 'POST',
        data: JSON.stringify(pData),
        cache: false,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (pData, textStatus, jqXHR) {
            var data = eval("(" + pData.d + ")");
            var strHTML = "";
            var parttem = '<div id="line_{0}" class="number" title="{1} {2}">{0}</div>';

            $.each(data, function (index, item) {
                strHTML += $.string.Format(parttem, index + 1, item.FirstName, item.LastName);
            });
            $("#ContentPlaceHolder1_line1").html(strHTML);
            // intervalLottery = setInterval(Ramdom, 2000);
           // intervalLottery = setInterval(Ramdom, 2000);
        },
        beforeSend: function (jqXHR, settings) {           //

        },
        error: function (jqXHR, textStatus, errorThrown) {
            //  overlay.Hide();
        },
        complete: function (XMLHttpRequest, textStatus) {
            // overlay.Hide();
        }
    });

}


var listNumber = 198;
var intervalLottery = null;
var intervalGetData = null;
function Ramdom() {
    $("#ContentPlaceHolder1_line1 div").removeClass('capability');
    var x = Math.floor((Math.random() * listNumber) + 1);
    $("#line_" + x).addClass('capability');
}
